﻿@model List<thailandProject.Models.PROPERTY>

@{
    ViewBag.Title = "Manage Properties";
}

<div id="Wrapper2">
    <div id="content_header">
        <div id="headerimage">
        </div>
        <div id="theheader">@ViewBag.Header</div>
    </div>
    <!-- Left Column begins here -->
    <aside id="sidebar-wrapper">
        <nav class="sidebar">
            <!-- CONTENT GOES HERE -->
            <div id="searchcontainer">
                @Html.ActionLink("Back to Index", "Index")
                <br /><br />
                @if (Model != null)
                {
                    int i = 0;
                    <table cellspacing="0" cellpadding="5" id="searchclienttable">
                        <tr id="searchclienttoprow">
                            <th class="searchclientcols20">
                                Name
                            </th>
                            <th class="searchclientcols20">
                                Location
                            </th>
                            <th class="searchclientcols35">
                                Type
                            </th>
                            <th style="width:5%;"><!-- View Column -->
                            </th>
                        </tr>
                        <tr>
                            <th colspan="5">
                                @Html.ActionLink("(+) Add New Property...", "AddProperty", null, new { @class = "addnewclient" })
                            </th>
                        </tr>
                    
                    @foreach (var prop in Model)
                    {
                        //Ensure that Model isn't null. It will be null on the first load
                        // if odd row, keep same row color
                        if (thailandProject.Models.UtilMethods.isOdd(i))
                        {
                         <tr style="background:url('/images/transblack1.png') repeat scroll 0 0 transparent;" class="searchclientrow">
                        
                            <td style="border-bottom:1px dotted #cccccc; font-weight:bold;">
                                @Html.DisplayFor(modelItem => prop.propName)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.DisplayFor(modelItem => prop.propLocation)
                            </td>
                            <td style="text-align:right; border-bottom:1px dotted #cccccc;">
                            @{
                            string edit_link = "../../Admin/EditProperty?propId=" + prop.propID;
                                string deactivate_link = "../../Admin/DeactivateProperty?propId=" + prop.propID;
                                <a href="@deactivate_link" onclick="return warning()"><img src="../../images/deactivatebutton_small.png" alt="delete" /></a>
                                <a href="@edit_link"><img class="deactivate" src="../../images/edit_icon_small.png" alt="view" /></a>
                            }
                            </td>
                        </tr>
                        }
                        // if not odd row, then show a slight color change for better view
                        else 
                        {
                         <tr class="searchclientrow">
                        
                            <td style="border-bottom:1px dotted #cccccc; font-weight:bold;">
                                @Html.DisplayFor(modelItem => prop.propName)
                            </td>
                            <td style="border-bottom:1px dotted #cccccc">
                                @Html.DisplayFor(modelItem => prop.propLocation)
                            </td>
                            <td style="text-align:right; border-bottom:1px dotted #cccccc;">
                            @{
                                string edit_link = "../../Admin/EditProperty?propId=" + prop.propID;
                                string deactivate_link = "../../Admin/DeactivateProperty?propId=" + prop.propID;
                                <a href="@deactivate_link" onclick="return warning()"><img src="../../images/deactivatebutton_small.png" alt="delete" /></a>
                                <a href="@edit_link"><img class="deactivate" src="../../images/edit_icon_small.png" alt="view" /></a>
                            }
                            </td>
                        </tr>
                        }
                        i++;
                    }
                        </table>
                }
            </div>
        </nav>
    </aside>
    <!-- Right column begins here -->
    <article id="contents">
        
    </article>
    <!-- Right column ends here -->
</div>
<!-- Div wrapper2 ends here -->

<script>
    function warning() {
        return confirm('Are you sure?\n\nThis will deactivate the property...');
    }
</script>
